<?php
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// |
// +----------------------------------------------------------------------

namespace app\model;

use \think\Model;

class AdminAgent extends Model
{
    protected $name = 'admin_agent';
    protected $autoWriteTimestamp = true;
    protected $insert = [];
    protected $update = [];

    //1 => '邀请推客', 2 => '邀请小店商家', 3 => '自定义分销比例'
    const RULE_INVITE_USER  = 1;
    const RULE_INVITE_SHOP  = 2;
    const RULE_CUSTOM_RATIO = 3;
    const RULE_ARRAY        = [
        self::RULE_INVITE_USER  => '推客邀请',
        self::RULE_INVITE_SHOP  => '店铺邀请',
        self::RULE_CUSTOM_RATIO => '佣金设置'
    ];

    public function setRulesAttr($value)
    {
        return $value ? implode(',', $value) : '';
    }

    public function getRulesAttr($value)
    {
        return $value ? explode(',', $value) : [];
    }
}
